package facilius.controller.action.tiponota;

import facilius.model.ServiceLocator;
import facilius.model.pojo.TipoNota;
import org.mentawai.core.BaseAction;

/**
 *
 * @author Graciano
 */
public class TipoNotaShowFormAction extends BaseAction{

    @Override
    public String execute() throws Exception {
        String consequence = ERROR;
        String formAction = "TipoNotaCreate.mtw";
        try {
            
            Long id = input.getLong("id");
            
            if (id != null && id > 0){
                formAction = "TipoNotaUpdate.mtw";

                TipoNota tipoNota = ServiceLocator.getTipoNotaService().readById(id);
                output.setValue("id", tipoNota.getId());
                output.setValue("descricao", tipoNota.getDescricao());
                output.setValue("oficial", tipoNota.isOficial());

            }
            
            output.setValue("formAction", formAction);
            
            consequence = SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return consequence;
    }



}
